package nova

import (
	"git.100tal.com/wangxiao_dahai_backend/arch-nova/middleware"
)

func NewAuthority() error {
	config := &middleware.AuthorityConfig{}
	config.HeaderAuthKey = GetString("authority.header_key")
	if config.HeaderAuthKey == "" {
		return ConfigNotFound("authority.header_key")
	}

	excludes := GetStringSlice("authority.excludes")
	for _, exclude := range excludes {
		config.Excludes[exclude] = true
	}

	err := middleware.NewAuthority(config)
	if err != nil {
		panic(err)
	}

	return nil
}
